//
// Created by 高森森 on 2022/11/16.
//

#ifndef BASECINE_GRAPH_H
#define BASECINE_GRAPH_H

#include <queue>
#include <vector>
#include <string.h>
#include <iostream>
#include "../utils/types.h"
#include "../utils/utils.h"
#include "../utils/globals.h"
#include "MatchRecord.h"

class Graph {
protected:
    uint edge_count_;//边个数
    uint vlabel_count_;//点标签个数
    uint elabel_count_;//边标签个数
    std::vector<std::vector<uint> > neighbors_;//邻接表
    std::vector<std::vector<uint> > elabels_;//边标签
    std::vector<std::vector<float>>weights_;//邻接表对应的边的权重
    std::vector<std::vector<uint>>timestamp_;//邻接表对应的边的时间戳


public:
    std::queue<InsertUnit> updates_;//更新结构 插入或者删除边
    std::vector<uint> vlabels_;//节点标签


public:
    Graph();

    virtual uint NumVertices() const { return vlabels_.size(); }
    virtual uint NumEdges() const { return edge_count_; }
    uint NumVLabels() const { return vlabel_count_; }
    uint NumELabels() const { return elabel_count_; }
    uint GetDiameter() const;

    void AddVertex(uint id, uint label);
    void RemoveVertex(uint id);
    void AddEdge(uint v1, uint v2, uint label,float weights,uint timestamp,uint flag);//增加边的权重限制
    void RemoveEdge(uint v1, uint v2);

    uint GetVertexLabel(uint u) const;
    float GetEdgeWeight(uint v1,uint v2)const;
    uint GetEdgeTime(uint v1,uint v2)const;
    const std::vector<uint>& GetNeighbors(uint v) const;
    const std::vector<uint>& GetNeighborLabels(uint v) const;
    const std::vector<float>& GetNeighborWeights(uint v) const;
    uint GetDegree(uint v) const;
    std::tuple<uint, uint, uint> GetEdgeLabel(uint v1, uint v2) const;

    //0是查询图 1是数据图
    void LoadFromFile(const std::string &path,const uint flag);

    //从数据流中提取到随着时间窗口移动的边的增删
    void createUpdateStream(const std::string data_path,const std::string dest_path);
    void createDataStream(const std::string data_path,const std::string dest_path);
    void createInitalDataGraph(const std::string data_path,const std::string dest_path);
    void LoadUpdateStream(const std::string &path);
    void PrintMetaData() const;
};


#endif //BASECINE_GRAPH_H
